<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateComplainsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('complains', function (Blueprint $table) {
            $table->increments('id');
            $table->bigInteger('match_order_id')->comment('撮合订单 ID');
            $table->string('reason')->comment('上传原因');
            $table->enum('type',['deposit','withdraw'])->comment('发起人还是提现人发起的申诉');
            $table->string('image_url')->comment('申诉人上传凭证');

            $table->unsignedBigInteger('created_at');
            $table->unsignedBigInteger('updated_at');
            $table->index(['match_order_id', 'type']);  // 唯一索引

            $table->foreign('match_orders')->references('id')->on('match_order_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('complains');
    }
}
